<%--
  Created by IntelliJ IDEA.
  User: 杨望
  Date: 2021/7/16
  Time: 10:30
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>评论列表</title>
    <style>
        #main{
            width: 800px;
            margin: 100px auto;
            border: 1px solid red;
        }
        #main div{
            text-align: center;
        }
        table{
            width: 800px;
            text-align: center;
        }
    </style>
</head>
<body>


<div id="main">
    <div>
        <h1>评论列表</h1>
        <form>
            <div>
                <%-- <c:if test="${not empty requestScope.ebookEntries}">
                     <c:forEach items="${ebookEntries}" var="ebookEntries">--%>



                <input type="hidden" name="pageNo" value="1" id="pageNo" />
                <input type="hidden" name="newsid" value="${requestScope.newsid}" id="newsid" />
                <%--value="${requestScope.ename}"实现查询后输入回显--%>
                    <%--<a href="/jsp/invadd.jsp">添加回复</a>--%>
                    <a href="/detail/mlist">返回新闻列表</a>

                <%-- </c:forEach>
             </c:if>--%>
            </div>
            <%--<div>
                &lt;%&ndash;超链接写点击不需写onclick&ndash;%&gt;
               &lt;%&ndash; <a href="javascript:delEmps()">删除多行</a>&ndash;%&gt;
                &lt;%&ndash;<a href="javascript:delEmps()">删除</a>&ndash;%&gt;
                &lt;%&ndash;${pageContext.request.contextPath}获取项目的上下文
                    其实就是项目名称
                &ndash;%&gt;
                <a href="${pageContext.request.contextPath}/jsp/invadd.jsp">添加</a>
            </div>--%>
    </div>
    </form>

    <table border="1" cellspacing="0">
<%--        <tr>

                <a href="${pageContext.request.contextPath}/detail/rlist?id=${replyDetails.id}"> 添加回复</a>
                &nbsp;&nbsp;&nbsp;&nbsp;
                <a href="javascript:deleteInvitation(${invitations.id})">返回帖子列表</a>


        </tr>--%>

        <tr>
            <%--<td><input type="checkbox" id="checkAll" onclick="checkAlls()" />全选/全不选</td>--%>
                <td>评论编号</td>
                <td>评论内容</td>
            <td>评论人</td>
            <td>评论时间</td>
            <%--<td>上传时间</td>--%>

        </tr>
        <c:if test="${not empty requestScope.pageInfo}">
            <c:forEach items="${requestScope.pageInfo.list}" var="newscomments" varStatus="status">
                <tr>
                        <%--<td><input type="checkbox" name="checkItem" onclick="checkItems()" value="${ebookEntries.id}" /></td>--%>
                    <td>${newscomments.id}</td>
                    <td>${newscomments.content}</td>
                    <td>${newscomments.author}</td>
                        <%--<td>${invitations.uploaduser}</td>--%>
                        <%--时间格式化--%>
                    <td><fmt:formatDate value="${newscomments.createdate}" pattern="yyyy年MM月dd日"></fmt:formatDate></td>
                        <%-- <td>${ebookEntries.sal}</td>
                         <td>${ebookEntries.comm}</td>
                         <td>${ebookEntries.deptno}</td>--%>
                   <%-- <td>
                            &lt;%&ndash;<a href="#">详情</a>&ndash;%&gt;
                        <a href="${pageContext.request.contextPath}/ebook/updateId?id=${ebookEntries.id}"> 查看回复</a>
                            &lt;%&ndash;<a href="#">修改</a>&ndash;%&gt;
                        <a href="javascript:deleteInvitation(${invitations.id})">删除</a>
                    </td>--%>
                </tr>
            </c:forEach>
        </c:if>

        <c:if test="${empty requestScope.pageInfo.list}">
            <tr>
                <td colspan="10" style="font-size: 20px;font-weight: bold;color: red">没有帖子信息</td>
            </tr>
        </c:if>
        <tr>
            <td colspan="10">
                <div class="page-bar">
                    <div class="page-num-ul clearfix">
                        共${pageInfo.total }条记录&nbsp;&nbsp; ${pageInfo.pageNum }/${pageInfo.pages}页</li>
                        <c:if test="${pageInfo.pageNum > 1}">
                            <a href="javascript:page_nav(document.forms[0],1);">首页</a>
                            <a href="javascript:page_nav(document.forms[0],${pageInfo.pageNum-1});">上一页</a>
                        </c:if>
                        <c:if test="${pageInfo.pageNum < pageInfo.pages }">
                            <a href="javascript:page_nav(document.forms[0],${pageInfo.pageNum+1});">下一页</a>
                            <a href="javascript:page_nav(document.forms[0],${pageInfo.pages });">最后一页</a>
                        </c:if>
                    </div>
                    <span class="page-go-form"><label>跳转至</label>
                        <!--GO-->
				<input type="hidden" name="" id="totalPageCount" value="${pageInfo.pages }" />
             <input type="text" name="inputPage" id="inputPage" class="page-key" />页
             <button type="button" class="page-btn" onClick='jump_to(document.forms[0],document.getElementById("inputPage").value)'>GO</button>
            </span>
                </div>
            </td>
        </tr>
    </table>
</div>
<script>
    function page_nav(frm,num) {

        frm.pageNo.value=num;
        frm.submit();
    }

    function jump_to(frm,num) {
        //alert(num);
        //验证用户的输入
        var regexp=/^[1-9]\d*$/;
        var totalPageCount=document.getElementById("totalPageCount").value;
        //alert(totalPageCount);
        if(!regexp.test(num)){
            alert("请输入大于0的正整数!");
            return false;
        }else if((num-totalPageCount)>0){
            alert("请输入小于总页码数的页码");
            return false;
        }else{
            page_nav(frm,num);
        }
    }
</script>

<!--导入js文件-->
<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-1.8.3.min.js"></script>
</body>
</html>
